﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;

using SolrExample.Tests;
using NUnit.Framework;
using Spring.Context;
using Spring.Context.Support;
using SolrExample.Common;
using SolrExample.Interface.DomainObject;
using SolrNet.Impl;
using SolrNet.Commands;
using SolrExample.Tests.SolrClient;
using System.Xml.Linq;

namespace SolrExample.Temp.Tests
{
    /// <summary>
    /// Summary description for UnitTest1
    /// </summary>
    [TestFixture]
    public class LinqReadXml
    {
        private static SearchEngineCommand mSearchEngine = new SearchEngineCommand();
        [TestFixtureSetUp]
        public void InitializeAllTests()
        {

        }

        [Test]
        public void Test1()
        {
            string filePath = @"D:\SolrExample\SolrExample.Tests\SolrSearchResult.xml";            
            XElement root = XElement.Load(filePath);
            IList<long> listJobAd = new List<long>();
            var list = (from T in root.Descendants("str")
                        where (string)T.Attribute("name") == "id"
                        select Convert.ToInt64(T.Value)).ToList();
            Console.WriteLine("count:" + list.Count);

            foreach (long i in list) {
                Console.WriteLine(i);
            }

            string s = "102,103,104";
            IList<long> list2 = s.Split(',').Select(c => Convert.ToInt64(c)).ToList();
            foreach (long i in list2)
            {
                Console.WriteLine(i);
            }
        }


        [TestFixtureTearDown]
        public void CleanupAllTests() { }

    }

}
